<?php
// +----------------------------------------------------------------------
// | ZanPianCMS [ WE CAN DO IT JUST THINK IT ]
// +----------------------------------------------------------------------
// | Copyright (c) 2013 http://www.zanpian.com All rights reserved.
// +----------------------------------------------------------------------
// | BBS:  <http://www.feifeicms.cc>
// +----------------------------------------------------------------------
namespace app\common\model;
use think\Model;
class Urls extends Model{
		//获取相关的数据转为字符串
		public function urls_data($id){
		$rs = db("Urls",[],false);
		$data['urls_id'] = $id;
		$list=$rs->where($data)->select();
		foreach($list as $key=>$val){
			$value[$key]=$val['urls_reurl'];
		}
		if($value){
			return $value;
			}else{
			return array();		
				}
		}
		public function urls_update($id,$urls){
		$rs = db("Urls",[],false);
		$data['urls_id'] = $id;
		$rs->where($data)->delete();
		if(is_array($urls)){
		$urls_arr = $urls;
		}
		else{
		$urls_arr = explode(',',$urls);	
		$urls_arr = array_filter(array_unique($urls_arr));	
			}
		foreach($urls_arr as $key=>$val){
			$datas[$key]['urls_id'] = $id;
			$datas[$key]['urls_reurl'] = $val;
		   }
		if(isset($datas)){
		$rs->insertAll($datas);   
		} 
		}

   
}